﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.FeatureBase;
using QLBH.ModelInterface;
using QLBH.Model.Controller;
using QLBH.FeatureBase.Modules.Category;
using PluginFramework.Common;

namespace QLBH.Category
{
    [ExtensionOf(typeof(PhieuChuyenKhoToolExtensionPoint))]
    public class ChuyenKhoTool : BaseView,IPhieuChuyenKhoTool
    {
        public FormViewBase GetView(object arg = null)
        {
            return new ChuyenKhoTool();
        }
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // ChuyenKhoTool
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.Name = "ChuyenKhoTool";
            this.Size = new System.Drawing.Size(943, 560);
            this.ResumeLayout(false);

        }
        public override void InitDataGridView()
        {
            base.InitDataGridView();
        }
        public override void LoadForm(object sender, System.EventArgs e)
        {
            base.LoadForm(sender, e);

            OnLoadDSPhieuChuyenKho();
        }

        private void OnLoadDSPhieuChuyenKho()
        {
            List<IPhieuChuyenKhoModel> results = new List<IPhieuChuyenKhoModel>();

            var items = PhieuChuyenKhoController.GetInstance().GetAll().ToList();

            foreach (var pck in items)
            {
                IPhieuChuyenKhoModel model = ModelFactory.ModelFactory.GetPhieuChuyenKhoInstance();
                model.InitFromEntity(pck);

                results.Add(model);
            }

            DataSource = results;

            DataGridView.DataSource = DataSource;

            //Setting for datagrid's columns

            DataGridView.Columns["PCKID"].Visible = false;
            DataGridView.Columns["PCKID"].DisplayIndex = 6;

            DataGridView.Columns["PCKCODE"].Visible = true;
            DataGridView.Columns["PCKCODE"].HeaderText = "Số phiếu";
            DataGridView.Columns["PCKCODE"].DisplayIndex = 0;

            DataGridView.Columns["USERID"].Visible = false;
            DataGridView.Columns["USERID"].DisplayIndex = 7;

            DataGridView.Columns["USERNAME"].Visible = true;
            DataGridView.Columns["USERNAME"].HeaderText = "Người tạo";
            DataGridView.Columns["USERNAME"].DisplayIndex = 4;

            DataGridView.Columns["KHOXUATID"].Visible = false;
            DataGridView.Columns["KHOXUATID"].DisplayIndex = 8;

            DataGridView.Columns["KHOXUATNAME"].Visible = true;
            DataGridView.Columns["KHOXUATNAME"].DisplayIndex = 1;
            DataGridView.Columns["KHOXUATNAME"].HeaderText = "Kho xuất";

            DataGridView.Columns["KHONHAPID"].Visible = false;
            DataGridView.Columns["KHONHAPID"].DisplayIndex = 9;

            DataGridView.Columns["KHONHAPNAME"].Visible = true;
            DataGridView.Columns["KHONHAPNAME"].HeaderText = "Kho nhập";
            DataGridView.Columns["KHONHAPNAME"].DisplayIndex = 2;

            DataGridView.Columns["NGAYCHUYEN"].Visible = true;
            DataGridView.Columns["NGAYCHUYEN"].HeaderText = "Ngày chuyển";
            DataGridView.Columns["NGAYCHUYEN"].DisplayIndex = 3;

            DataGridView.Columns["GHICHU"].Visible = true;
            DataGridView.Columns["GHICHU"].HeaderText = "Ghi chú";
            DataGridView.Columns["GHICHU"].DisplayIndex = 5;

            DataGridView.Columns["PHIEUCHIID"].Visible = false;
            DataGridView.Columns["PHIEUCHIID"].DisplayIndex = 10;
        }

        public override void AddNew(object sender, EventArgs e)
        {
            base.AddNew(sender, e);
        }
        public override void EditItem(object sender, EventArgs e)
        {
            base.EditItem(sender, e);
        }
        public override void DeleteItem(object sender, EventArgs e)
        {
            base.DeleteItem(sender, e);
        }


       
    }
}
